<template>
	<view class="admin">
		<view class="list">
			<view>
				<uni-section v-for="(item,index) in caseData" :title="item.name || '我的病例'" type="line">
					<uni-card :title="`${item.sex == 0 ? '男':'女'}性`" :extra="`${item.age}岁`">
						<view class="uni-body" @click.stop="openMask(item)">
							<uni-section title="点击查看详细详细" type="line" padding>
								<uni-steps :options="list1" :active="item.nowPosition-1" />
							</uni-section>
						</view>
					</uni-card>
				</uni-section>
				<!-- <uni-collapse accordion v-model="accordionValUser">
					<uni-collapse-item :title="(`医生：${item.doctorName} (${item.isConduct==true?'进行中':'已完成'})`)"
						v-for="(item,index) of caseData">
						<view class="content">
							<view>姓名：{{item.name}}</view>
							<view>年龄：{{item.age}}</view>
							<view>性别：{{item.sex == 0 ? '男':'女'}}</view>
							<view>手机号：{{item.mobilePhone}}</view>
							<view>病情：{{item.disease}}</view>
						</view>
					</uni-collapse-item>
				</uni-collapse> -->
			</view>
		</view>



		<uni-popup ref="popup" background-color="#ffffffb8">
			<view class="popup-content" :class="{ 'popup-height': type === 'left' || type === 'right' }">
				<view class="">姓名：{{info.name || '--'}}</view>
				<view class="">年龄：{{info.age || '--'}}</view>
				<view class="">性别：{{info.sex?'男':'女' || '--'}}</view>
				<view class="">电话：{{info.mobilePhone || '--'}}</view>
				<view class="">医师：{{info.doctorName || '--'}}</view>
				<view class="">症状：{{info.disease || '--'}}</view>
				<!-- <view class="status status1" v-if="info.nowPosition == 1">
					已提交
				</view>
				<view class="status status2" @click="info.nowPosition = 3" v-if="info.nowPosition == 2">
					处理中
				</view>
				<view class="status status3" v-if="info.nowPosition == 3">
					已完成
				</view> -->
				<view class="baoGao" v-if="info.nowPosition >= 2">
					<!-- <view class="baoGao"> -->
					医生建议：<text @click="baoGao = !baoGao">点击查看建议</text>
					<view class="content" v-if="baoGao">
						{{info.evaluate || '---'}}
					</view>
				</view>

				<button v-if="info.nowPosition == 2" @click="overBtn">问诊结束</button>

				<!-- this.$refs.popup.close() -->
				<!-- info.nowPosition  = 3 -->

				<view class="">个人评价：{{info.disease || '--'}}</view>

			</view>
		</uni-popup>


		<uni-popup ref="inputDialog" type="dialog">
			<uni-popup-dialog ref="inputClose" mode="input" title="对该次问诊进行评价" placeholder="请输入内容"
				@confirm="dialogInputConfirm"></uni-popup-dialog>
		</uni-popup>



	</view>
</template>

<script>
	export default {
		data() {
			return {
				accordionValUser: '',
				caseData: [],

				userManagement: [],
				active: 1,
				list1: [{
					title: '已提交'
				}, {
					title: '处理中'
				}, {
					title: '已完成'
				}],
				type: 'center',
				baoGao: false,
				info: {},
				// userEvaluate: ''
			}
		},

		created() {
			this.userManagement = this.$store.state.userManagement
			this.caseData = this.$store.state.currentUser.registrationData
			console.log(this.caseData);
		},

		methods: {
			onClickItem(e) {
				if (this.current !== e.currentIndex) {
					this.current = e.currentIndex
				}
			},
			openMask(n) {
				console.log(n);
				this.info = n
				// open 方法传入参数 等同在 uni-popup 组件上绑定 type属性
				this.$refs.popup.open("center")
			},
			overBtn() {
				this.info.nowPosition = 3
				this.$refs.popup.close()
				this.$refs.inputDialog.open()

			},
			dialogInputConfirm(val) {
				// this.currentPatient.registrationData[0].evaluate = val

				// this.currentPatient.registrationData[0].isConduct = false
				// this.myPatient.splice(this.myPatient.indexOf(this.currentPatient), 1)
				this.caseData[0].userEvaluate = val

				this.$store.state.currentUser.registrationData = this.caseData

				console.log(this.caseData[0]);
				this.userManagement = this.userManagement.map(item => {
					if (item.account == this.$store.state.currentUser.account) {
						item = this.$store.state.currentUser
					}
					return item
				})
				// console.log(this.currentPatient, 111111);
				this.$store.commit('getLogin', this.$store.state.currentUser)
				this.$store.commit('setUserData', this.userManagement)
			}
		}
	}
</script>

<style lang="scss">
	.admin {
		width: 100vw;
		height: 100vh;

		opacity: 0.8;
		background: linear-gradient(white, transparent);
		overflow: auto;

		.popup-content {
			padding: 50rpx;

			>view {
				// outline: 1px solid red;
				padding: 10rpx;
				width: 50vw;
				word-wrap: break-word;
				word-break: break-all;
			}

			.status {
				width: fit-content;
				border-radius: 20rpx;
				padding: 10rpx 20rpx;
				margin: auto;
			}

			.status1 {
				background: #1cffac90;
			}

			.status2 {
				background: #fff82190;
			}

			.status3 {
				background: #ff737590;
				color: white;
			}

			.baoGao {
				.content {
					background: #ffffff90;
					padding: 20rpx;
					color: #ff9092;
					border-radius: 20rpx;
				}
			}
		}



		.admin-nav {
			width: 650rpx;
			margin: 0 auto
		}

		.list {
			margin-top: 20rpx;

			.content {
				padding: 0 25rpx;
				display: flex;
				justify-content: space-between;
				flex-wrap: wrap;

				view {
					width: 320rpx;
					margin: 10rpx 0 20rpx 20rpx;
					white-space: warp;
				}
			}

			.btn {
				height: 80rpx;
				display: flex;
				justify-content: center;

				view {
					width: 100rpx;
					height: 50rpx;
					line-height: 50rpx;
					text-align: center;
					background-color: red;
					margin-right: 20rpx;
					color: white;
				}

				.edit {
					background-color: skyblue;
				}
			}
		}
	}
</style>
